/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import BUS.DichVu_BUS;
import BUS.KhachHang_BUS;
import BUS.LoaiPhong_BUS;
import BUS.MonAn_BUS;
import BUS.Phong_BUS;
import DTO.LoaiPhong_DTO;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author PEKEM
 */
public final class FrameTimKiem extends javax.swing.JFrame {

    DefaultTableModel tbModelMA;
    DefaultTableModel tbModelDV;
    DefaultTableModel tbModelPhong;
    DefaultTableModel modelKhach;

    /**
     * Creates new form FrameTimKiem
     */
    public FrameTimKiem() throws Exception {
        initComponents();
        this.setSize(852, 650);
        this.setIconImage(Toolkit.getDefaultToolkit().getImage("src/Image/tracuuphong.png"));
        tbModelMA = MonAn_BUS.layBangMonAn();
        tbMonAn.setModel(tbModelMA);
        tbModelDV = DichVu_BUS.layBangDichVu();
        tbDichVu.setModel(tbModelDV);

        showcbbTenLoaiPhong();
        showPhong();

        showKhach();
    }

    public void showPhong() {
        try {
            tbModelPhong = Phong_BUS.layDanhSachPhong();
        } catch (Exception ex) {
            Logger.getLogger(TimPhong.class.getName()).log(Level.SEVERE, null, ex);
        }
        tablePhong.setModel(tbModelPhong);
    }

    protected void showcbbTenLoaiPhong() {

        DefaultComboBoxModel cbbModel = (DefaultComboBoxModel) cbbTenLoaiPhong.getModel();
        ArrayList<LoaiPhong_DTO> ds = new ArrayList<>();
        try {
            ds = LoaiPhong_BUS.layDanhSachTenLoaiPhong();
        } catch (Exception e) {
        }

        for (LoaiPhong_DTO lp : ds) {
            cbbModel.addElement(lp.getTenloaiPhong());
        }
    }

    public void showKhach() {
        try {
            modelKhach = KhachHang_BUS.layDSKhach();
        } catch (Exception ex) {
            Logger.getLogger(TimKhach.class.getName()).log(Level.SEVERE, null, ex);
        }
        tableKhach.setModel(modelKhach);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        tabTimKiem = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbMonAn = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        btTimMA = new javax.swing.JButton();
        tfDen = new javax.swing.JTextField();
        tfTu = new javax.swing.JTextField();
        tfTenMonAn = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbDichVu = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tfTenDichVu = new javax.swing.JTextField();
        tfTuDV = new javax.swing.JTextField();
        tfDenDV = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        btTimDV = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        cbbTenLoaiPhong = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        cbbTinhTrang = new javax.swing.JComboBox();
        btTim = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablePhong = new javax.swing.JTable();
        jPanel7 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        tfTenKhach = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        tfCMND = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        tableKhach = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                formComponentMoved(evt);
            }
        });

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        tbMonAn.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbMonAn);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btTimMA.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Search.png"))); // NOI18N
        btTimMA.setText("Tìm Theo Giá");
        btTimMA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTimMAActionPerformed(evt);
            }
        });

        tfDen.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfDen.setText("0");

        tfTu.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfTu.setText("0");

        tfTenMonAn.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                tfTenMonAnFocusGained(evt);
            }
        });
        tfTenMonAn.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tfTenMonAnKeyTyped(evt);
            }
        });

        jLabel1.setText("Tên Món Ăn");

        jLabel3.setText("Từ:");

        jLabel2.setText("Đơn Giá");

        jLabel4.setText("Đến:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(11, 11, 11)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(tfDen, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTu)
                    .addComponent(tfTenMonAn))
                .addGap(18, 18, 18)
                .addComponent(btTimMA)
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(tfTenMonAn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfTu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2))
                        .addGap(13, 13, 13)))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tfDen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btTimMA)
                .addContainerGap())
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {tfDen, tfTenMonAn, tfTu});

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 673, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(87, 87, 87))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
                .addContainerGap())
        );

        tabTimKiem.addTab("Tìm Kiếm Món Ăn", new javax.swing.ImageIcon(getClass().getResource("/Image/trogiup.png")), jPanel1); // NOI18N

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        tbDichVu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tbDichVu);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel7.setText("Tên Dịch Vụ");

        jLabel8.setText("Đơn Giá");

        jLabel6.setText("Từ:");

        tfTenDichVu.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tfTenDichVuKeyTyped(evt);
            }
        });

        tfTuDV.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfTuDV.setText("0");

        tfDenDV.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfDenDV.setText("0");

        jLabel5.setText("Đến:");

        btTimDV.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Search.png"))); // NOI18N
        btTimDV.setText("Tìm Theo Giá");
        btTimDV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTimDVActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(70, 70, 70)
                        .addComponent(jLabel5)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(tfTenDichVu, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTuDV, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfDenDV))
                .addGap(30, 30, 30)
                .addComponent(btTimDV)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {tfDenDV, tfTenDichVu, tfTuDV});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(tfTenDichVu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel6)
                    .addComponent(tfTuDV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(tfDenDV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btTimDV))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {tfDenDV, tfTenDichVu, tfTuDV});

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(99, 99, 99)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 652, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(202, 202, 202)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(103, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                .addGap(22, 22, 22))
        );

        tabTimKiem.addTab("Tìm Kiếm Dịch Vụ", new javax.swing.ImageIcon(getClass().getResource("/Image/Search.png")), jPanel2); // NOI18N

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel9.setText("Tìm theo tên loại phòng");

        cbbTenLoaiPhong.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbTenLoaiPhongItemStateChanged(evt);
            }
        });

        jLabel10.setText("Tìm theo tình trạng phòng");

        cbbTinhTrang.setEditable(true);
        cbbTinhTrang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Trống", "Đang đặt", "Đang thuê" }));
        cbbTinhTrang.setToolTipText("");
        cbbTinhTrang.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbTinhTrangItemStateChanged(evt);
            }
        });

        btTim.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Search.png"))); // NOI18N
        btTim.setText("Tìm ");
        btTim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTimActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(34, 34, 34)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbbTenLoaiPhong, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbbTinhTrang, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(69, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btTim)
                .addGap(48, 48, 48))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(cbbTenLoaiPhong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(cbbTinhTrang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btTim)
                .addContainerGap())
        );

        jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        tablePhong.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        tablePhong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane3.setViewportView(tablePhong);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(220, 220, 220)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 805, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(21, 21, 21))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
                .addContainerGap())
        );

        tabTimKiem.addTab("Tìm phòng", new javax.swing.ImageIcon(getClass().getResource("/Image/tracuuphong.png")), jPanel5); // NOI18N

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel11.setText("Tìm khách theo tên");

        tfTenKhach.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tfTenKhachKeyTyped(evt);
            }
        });

        jLabel12.setText("Tìm khách theo CMND");

        tfCMND.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tfCMNDKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabel11))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(tfTenKhach)
                    .addComponent(tfCMND, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE))
                .addGap(19, 19, 19))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(tfTenKhach, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(tfCMND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jScrollPane4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        tableKhach.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(tableKhach);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(139, 139, 139)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 566, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(243, 243, 243)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(149, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(87, Short.MAX_VALUE))
        );

        tabTimKiem.addTab("Tìm khách", new javax.swing.ImageIcon(getClass().getResource("/Image/khach.png")), jPanel7); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabTimKiem)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabTimKiem, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tfTenMonAnKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfTenMonAnKeyTyped
        // TODO add your handling code here:
        String tenMA = tfTenMonAn.getText();
        try {
            if (!"".equals(tenMA)) {
                tbModelMA = MonAn_BUS.layBangMonAnTheoTen(tenMA);
                tbMonAn.setModel(tbModelMA);
            }
        } catch (Exception ex) {
            Logger.getLogger(FrameTimKiem.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_tfTenMonAnKeyTyped

    private void btTimMAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTimMAActionPerformed
        // TODO add your handling code here: 
        tfTenMonAn.setText("");
        Float tu;
        Float den;
        try {
            tu = Float.parseFloat(tfTu.getText());
            if (tu < 0 || tu > 10000000) {
                JOptionPane.showMessageDialog(rootPane, "Giá từ phải là số từ 0 đến 10000000!");
                tfTu.setText("0");
                return;
            }
        } catch (NumberFormatException | HeadlessException e) {
            JOptionPane.showMessageDialog(rootPane, "Giá từ phải là số từ 0 đến 10000000!");
            tfTu.setText("0");
            return;
        }
        try {
            den = Float.parseFloat(tfDen.getText());
            if (den < 0 || den > 10000000) {
                JOptionPane.showMessageDialog(rootPane, "Giá đến phải là số từ 0 đến 10000000!");
                tfDen.setText("0");
                return;
            }
        } catch (NumberFormatException | HeadlessException e) {
            JOptionPane.showMessageDialog(rootPane, "Giá đến phải là số từ 0 đến 10000000!");
            tfDen.setText("0");
            return;
        }
        if (tu > den) {
            JOptionPane.showMessageDialog(rootPane, "Giá đến phải lớn hơn giá từ!");
            return;
        }
        if (den != 0) {
            try {
                tbModelMA = MonAn_BUS.layBangMonAnTheoDonGia(tu, den);
                tbMonAn.setModel(tbModelMA);
            } catch (Exception ex) {
                Logger.getLogger(FrameTimKiem.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
        }
    }//GEN-LAST:event_btTimMAActionPerformed

    private void tfTenDichVuKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfTenDichVuKeyTyped
        // TODO add your handling code here:
        String tenDV = tfTenDichVu.getText();
        try {
            if (!"".equals(tenDV)) {
                tbModelDV = DichVu_BUS.layBangDichVuTheoTen(tenDV);
                tbDichVu.setModel(tbModelDV);
            }
        } catch (Exception ex) {
            Logger.getLogger(FrameTimKiem.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_tfTenDichVuKeyTyped

    private void btTimDVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTimDVActionPerformed
        // TODO add your handling code here:
        tfTenDichVu.setText("");
        Float tu;
        Float den;
        try {
            tu = Float.parseFloat(tfTuDV.getText());
            if (tu < 0 || tu > 10000000) {
                JOptionPane.showMessageDialog(rootPane, "Giá từ phải là số từ 0 đến 10000000!");
                tfTuDV.setText("0");
                return;
            }
        } catch (NumberFormatException | HeadlessException e) {
            JOptionPane.showMessageDialog(rootPane, "Giá từ phải là số từ 0 đến 10000000!");
            tfTuDV.setText("0");
            return;
        }
        try {
            den = Float.parseFloat(tfDenDV.getText());
            if (den < 0 || den > 10000000) {
                JOptionPane.showMessageDialog(rootPane, "Giá đến phải là số từ 0 đến 10000000!");
                tfDenDV.setText("0");
                return;
            }
        } catch (NumberFormatException | HeadlessException e) {
            JOptionPane.showMessageDialog(rootPane, "Giá đến phải là số từ 0 đến 10000000!");
            tfDenDV.setText("0");
            return;
        }
        if (tu > den) {
            JOptionPane.showMessageDialog(rootPane, "Giá đến phải lớn hơn giá từ!");
            return;
        }
        if (den != 0) {
            try {
                tbModelDV = DichVu_BUS.layBangDichVuTheoDonGia(tu, den);
                tbDichVu.setModel(tbModelDV);
            } catch (Exception ex) {
                Logger.getLogger(FrameTimKiem.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btTimDVActionPerformed

    private void tfTenMonAnFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfTenMonAnFocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_tfTenMonAnFocusGained

    private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved
        // TODO add your handling code here:
        this.setLocationRelativeTo(FrameMenu.menu.pannelDestop);
    }//GEN-LAST:event_formComponentMoved

    private void cbbTenLoaiPhongItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbTenLoaiPhongItemStateChanged
        try {
            // TODO add your handling code here:
            tbModelPhong = Phong_BUS.timPhongTheoTenLoaiPhong(cbbTenLoaiPhong.getSelectedItem().toString());
            tablePhong.setModel(tbModelPhong);
        } catch (Exception ex) {
            Logger.getLogger(TimPhong.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cbbTenLoaiPhongItemStateChanged

    private void cbbTinhTrangItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbTinhTrangItemStateChanged
        try {
            // TODO add your handling code here:
            tbModelPhong = Phong_BUS.timPhongTheoTinhTrang(cbbTinhTrang.getSelectedItem().toString());
        } catch (Exception ex) {
            Logger.getLogger(TimPhong.class.getName()).log(Level.SEVERE, null, ex);
        }
        tablePhong.setModel(tbModelPhong);
    }//GEN-LAST:event_cbbTinhTrangItemStateChanged

    private void btTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTimActionPerformed
        try {
            // TODO add your handling code here:
            tbModelPhong = Phong_BUS.timPhongTheoTLP_TT(cbbTinhTrang.getSelectedItem().toString(), cbbTenLoaiPhong.getSelectedItem().toString());
        } catch (Exception ex) {
            Logger.getLogger(TimPhong.class.getName()).log(Level.SEVERE, null, ex);
        }
        tablePhong.setModel(tbModelPhong);

    }//GEN-LAST:event_btTimActionPerformed

    private void tfTenKhachKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfTenKhachKeyTyped
        try {
            // TODO add your handling code here:
            modelKhach = KhachHang_BUS.timKhachTheoTen(tfTenKhach.getText());
        } catch (Exception ex) {
            Logger.getLogger(TimKhach.class.getName()).log(Level.SEVERE, null, ex);
        }
        tableKhach.setModel(modelKhach);
    }//GEN-LAST:event_tfTenKhachKeyTyped

    private void tfCMNDKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfCMNDKeyTyped
        try {
            // TODO add your handling code here:
            modelKhach = KhachHang_BUS.timKhachTheoCMND(tfCMND.getText());
        } catch (Exception ex) {
            Logger.getLogger(TimKhach.class.getName()).log(Level.SEVERE, null, ex);
        }
        tableKhach.setModel(modelKhach);
    }//GEN-LAST:event_tfCMNDKeyTyped

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
         FrameMenu.menu.setEnabled(true);
    }//GEN-LAST:event_formWindowClosing

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameTimKiem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameTimKiem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameTimKiem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameTimKiem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new FrameTimKiem().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(FrameTimKiem.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btTim;
    private javax.swing.JButton btTimDV;
    private javax.swing.JButton btTimMA;
    private javax.swing.JComboBox cbbTenLoaiPhong;
    private javax.swing.JComboBox cbbTinhTrang;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane tabTimKiem;
    private javax.swing.JTable tableKhach;
    private javax.swing.JTable tablePhong;
    private javax.swing.JTable tbDichVu;
    private javax.swing.JTable tbMonAn;
    private javax.swing.JTextField tfCMND;
    private javax.swing.JTextField tfDen;
    private javax.swing.JTextField tfDenDV;
    private javax.swing.JTextField tfTenDichVu;
    private javax.swing.JTextField tfTenKhach;
    private javax.swing.JTextField tfTenMonAn;
    private javax.swing.JTextField tfTu;
    private javax.swing.JTextField tfTuDV;
    // End of variables declaration//GEN-END:variables
}
